<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace App\Services;

use App\Enums\ArticleTypeEnum;

/**
 * 首页内容
 * 傻逼微信
 *
 * Class HomeService
 */
class HomeService
{
    protected $articleService;

    protected $bannerService;

    public function __construct(ArticleService $articleService, BannerService $bannerService)
    {
        $this->articleService = $articleService;
        $this->bannerService = $bannerService;
    }

    public function home()
    {
        $allLists = [];
        // 党政风采
        $dangzheng = $this->articleService->getArticleListByType(ArticleTypeEnum::ArticleTypeDangZheng, 1, 3);
        array_push($allLists, [
            'title' => ArticleTypeEnum::desc(ArticleTypeEnum::ArticleTypeDangZheng),
            'list' => $dangzheng['list'],
            'xcx_more_url' => '',
            'web_more_url' => '',
        ]);
        // 村务宣传
        array_push($allLists, [
            'title' => '村务宣传',
            'list' => [
                [
                    'title' => '村务新闻',
                    'cover_url' => 'https://image.hanlingsha.love/lwa/banner/2020-11-27/D1761640EF5D29428D27B84D39035250.jpg',
                    'xcx_list_url' => '/pages/news/index',
                    'web_list_url' => 'https://image.hanlingsha.love/lwa/banner/2020-11-27/D1761640EF5D29428D27B84D39035250.jpg',
                ],
                [
                    'title' => '网格管理',
                    'cover_url' => 'https://image.hanlingsha.love/lwa/banner/2020-11-27/D1761640EF5D29428D27B84D39035250.jpg',
                    'xcx_list_url' => '/pages/gridPropaganda/index ',
                    'web_list_url' => 'https://image.hanlingsha.love/lwa/headicon/2021-04-15/B85A31EB64F482EF44CBDEB6FF49C1C5.jpg',
                ],
            ],
            'xcx_more_url' => '',
            'web_more_url' => '',
        ]);
        // 政策解读
        $zhengce = $this->articleService->getArticleListByType(ArticleTypeEnum::ArticleTypeZhengce, 1, 3);
        array_push($allLists, [
            'title' => ArticleTypeEnum::desc(ArticleTypeEnum::ArticleTypeZhengce),
            'list' => $zhengce['list'],
            'xcx_more_url' => '',
            'web_more_url' => '',
        ]);
        // 盏新东窑
        $zhanxin = $this->articleService->getArticleListByType(ArticleTypeEnum::ArticleTypeZhanXin, 1, 4);
        array_push($allLists, [
            'title' => ArticleTypeEnum::desc(ArticleTypeEnum::ArticleTypeZhanXin),
            'list' => $zhanxin['list'],
            'xcx_more_url' => '',
            'web_more_url' => '',
        ]);

        // 流动人口管理
        array_push($allLists, [
            'title' => '流动人口管理',
            'list' => [
                [
                    'title' => '积分政策',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
                [
                    'title' => '信息录入',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
                [
                    'title' => '考核结果',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
                [
                    'title' => '办事评价',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
            ],
        ]);

        // 企业管理
        array_push($allLists, [
            'title' => '企业管理',
            'list' => [
                [
                    'title' => '企业信息公告',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
                [
                    'title' => '基础信息录入',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
                [
                    'title' => '企业积分政策',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
            ],
        ]);

        // 便民信息
        $bianmin = $this->articleService->getArticleListByType(ArticleTypeEnum::ArticleTypeBianMin, 1, 3);
        array_push($allLists, [
            'title' => ArticleTypeEnum::desc(ArticleTypeEnum::ArticleTypeBianMin),
            'list' => $bianmin['list'],
            'xcx_more_url' => '',
            'web_more_url' => '',
        ]);

        // 暖心服务
        array_push($allLists, [
            'title' => '暖心服务',
            'list' => [
                [
                    'title' => '房东排名',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
                [
                    'title' => '窑相呼应',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
                [
                    'title' => '寻物/寻人\\n启示',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
                [
                    'title' => '荣辱榜',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
                [
                    'title' => '垃圾分类',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
                [
                    'title' => '积分商城',
                    'cover_url' => '',
                    'xcx_list_url' => '',
                    'web_list_url' => '',
                ],
            ],
        ]);

        return [
            'banner' => $this->bannerService->getBanners(),
            'list' => $allLists,
        ];
    }

    public function homeSearch(string $title, int $page, int $pageSize)
    {
        return $this->articleService->searchArtices($title, $page, $pageSize);
    }
}
